package com.example.nacosconfig.controller;

import com.example.nacosconfig.entity.SysUser;
import com.example.nacosconfig.entity.TAuthUser;
import com.example.nacosconfig.service.SysUserService;
import com.example.nacosconfig.service.UserAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 测试 mybatis plus dynamic datasource 动态切换数据源
 */
@RestController
public class UserController {

    @Autowired
    public UserAuthService userAuthService;

    @Autowired
    public SysUserService sysUserService;


    /**
     * 使用数据源1的服务
     * @return
     */
    @RequestMapping("/getAllOld")
    public List<TAuthUser> getAllOld(){
        return userAuthService.getAll();
    }

    /**
     * 使用数据源2的服务
     * @return
     */
    @RequestMapping("/getAllNew")
    public List<SysUser> getAllNew(){
        return sysUserService.getAll();
    }
}
